package com.lingchou.cloud.process.client.cmd;

import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.Process;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;

import java.io.Serializable;

public class GetProcessCmd implements Command<Process>,Serializable {

    private static final long serialVersionUID = 1437115519351132006L;

    String processDefinitionId;

    public GetProcessCmd(String processDefinitionId) {
        this.processDefinitionId = processDefinitionId;
    }

    @Override
    public Process execute(CommandContext commandContext) {
        BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
        Process process = bpmnModel.getProcesses().get(0);
        return process;
    }

}